<?php
class IndexAction extends Action
{
    /**
    +----------------------------------------------------------
    *显示首页
    +----------------------------------------------------------
    */

    public function index()
    {
        $this->display();
    }

    
   /**
   /**
    +----------------------------------------------------------
    *判断登录
    +----------------------------------------------------------
    */
    public function checklogin()
    {
       $admin=new Model('Admin');
       $admin_name=isset($_POST['ad_name'])?addslashes(trim($_POST['ad_name'])):" ";
       $admin_pwd=isset($_POST['ad_pwd'])?addslashes(trim($_POST['ad_pwd'])):" ";
       $admin_ver=isset($_POST['ad_ver'])?addslashes(trim($_POST['ad_ver'])):" ";
        if(empty($admin_name))
       {
           $this->ajaxReturn('','用户名必须!',0);
       }
       elseif(empty($admin_pwd))
       {
           $this->ajaxReturn('','密码必须!',0);
       }
       elseif(empty($admin_ver))
       {

           $this->ajaxReturn('','验证码必须!',0);
       }
        ##生成认证条件
       $map['ad_name']=$admin_name;
       $map['ad_id']=array('gt',0);
       $admin_info=$admin->where($map)->select();
       if(false==$admin_info)
       {
           $this->ajaxReturn('','用户名不存在',0);
       }
       else
       {
           if($admin_info[0]['ad_name']!=$admin_name)
           {
               $this->ajaxReturn('','用户名错误',0);
           }
           if(trim($admin_info[0]['ad_pwd'])!=md5($admin_pwd))
           {
               $this->ajaxReturn('','密码错误',0);
           }
          
            if($_SESSION['verify']!=md5($admin_ver))
           {
               $this->ajaxReturn('','验证码错误',0);
           }
          // Session::set(C('ADMIN_ID'), $admin_name);
		   session(C('ADMIN_ID'), $admin_name);
		   $this->success('dengluchenggong','');
           $this->ajaxReturn('','登录成功',1);

       }

    }
    /**
    +----------------------------------------------------------
    * 生成验证码
    +----------------------------------------------------------
    */
    Public function verify()
    {
      import("ORG.Util.Image");
      Image::buildImageVerify();
     }
     /**
    +----------------------------------------------------------
    *显示topframe
    +----------------------------------------------------------
    */

    public function topframe()
    {
        if(!Session::is_set(C('ADMIN_ID')))
         {
           $this->assign("jumpUrl","index");
           $this->error("您无权访问!");

         }
         else
         {
         $this->display("topframe");
         }
    }
    /**
    +----------------------------------------------------------
    *显示leftframe
    +----------------------------------------------------------
    */

    public function leftframe()
    {
        if(!Session::is_set(C('ADMIN_ID')))
         {
           $this->assign("jumpUrl","index");
           $this->error("您无权访问!");

         }
         else
         {
         $admin=Session::get(C('ADMIN_ID'));
         $this->assign("admin",$admin);
         $this->display("leftframe");
         }
    }
    /**
    +----------------------------------------------------------
    *显示manframe
    +----------------------------------------------------------
    */
    public function manframe()
    {
       if(!Session::is_set(C('ADMIN_ID')))
         {
           $this->assign("jumpUrl","index");
           $this->error("您无权访问!");

         }
         else
         {
         $this->display("manframe");
         }
    }
     /**
    +----------------------------------------------------------
    * 注销session,安全退出
    +----------------------------------------------------------
    */
    public function logout()
    {
        Session::destroy(C('ADMIN_ID'));
        $this->assign("jumpUrl","index");
        $this->success("退出成功");
    }

}
?>